package cn.jishiyu11.xeqb.control

import android.content.Context
import android.os.Build
import android.support.annotation.RequiresApi
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.GridView

/**
 * Created by vvguoliang on 2017/7/25.
 * 自定义 Gridview
 */

class MyGridView : GridView {

    constructor(context: Context) : super(context) {}

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
    }

    /**
     * 设置上下不滚动
     */
    override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
        //true:禁止滚动
        return ev.action == MotionEvent.ACTION_MOVE || super.dispatchTouchEvent(ev)

    }
}
